#include <iostream>
#include <string>
#include <cstdlib>
#include <cstring>

#include <xapian.h>

using std::cin;
using std::cout;
using std::endl;
using std::string;

int index(char* subject, char* note) {
  try {
    Xapian::WritableDatabase db(subject, Xapian::DB_CREATE_OR_OPEN);
    Xapian::TermGenerator indexer;
    Xapian::Stem stemmer("english");
    indexer.set_stemmer(stemmer);

    Xapian::Document doc;
    doc.set_data(note);

    indexer.set_document(doc);
    indexer.index_text(note);

    db.add_document(doc);
    db.commit();
  } catch (const Xapian::Error &e) {
    cout << e.get_description() << endl;
    exit(1);
  }
}
